// https://umijs.org/config/
import { defineConfig } from 'umi';
import defaultSettings from './defaultSettings';
import proxy from './proxy';

const { REACT_APP_ENV } = process.env;

export default defineConfig({
  hash: true,
  antd: {},
  dva: {
    hmr: true,
  },
  layout: {
    name: '门禁管理',
    locale: false,
    siderWidth: 230,
  },
  locale: {
    // default zh-CN
    default: 'zh-CN',
    // default true, when it is true, will use `navigator.language` overwrite default
    antd: true,
    baseNavigator: false,
  },
  dynamicImport: {
    loading: '@/components/PageLoading/index',
  },
  targets: {
    ie: 11,
  },
  // umi routes: https://umijs.org/docs/routing
  routes: [
    {
      path: '/user',
      layout: false,
      routes: [
        {
          name: 'login',
          path: '/user/login',
          component: './user/login',
        },
      ],
    },

    {
      name: 'entryPage',
      path: '/entry',
      component: './Entry',
      flatMenu: true,
      routes: [
        {
          path: '/entry',
          redirect: '/entry/index',
        },
        {
          name: '首页',
          iconUrl: 'iconshouye',
          icon: '',
          path: '/entry/index',
          component: './Index',
        },
        // {
        //   name: 'list.table-list',
        //   icon: 'table',
        //   path: '/entry/list',
        //   component: './ListTableList',
        // },
        {
          path: '/entry/entranceGuardManagement/accessRecords',
          name: '出入记录',
          icon: '',
          iconUrl: 'iconshurujilu',
          component: './AccessRecords',
        },
        {
          path: '/entry/entranceGuardManagement/alarm',
          name: '告警管理',
          icon: '',
          iconUrl: 'icongaojingguanli',
          component: './Alarm',
        },
        {
          path: '/entry/entranceGuardManagement/doorManagement',
          name: '门管理',
          icon: '',
          iconUrl: 'iconmenguanli',
          component: './Door',
        },
        {
          path: '/entry/entranceGuardManagement/doorGroupManagement',
          name: '门组管理',
          icon: '',
          iconUrl: 'iconmenzuguanli',
          component: './DoorGroup',
        },
        {
          path: '/entry/entranceGuardManagement/cardManagement',
          name: '卡片管理',
          icon: '',
          iconUrl: 'iconkapianguanli',
          component: './Card',
        },
        {
          path: '/entry/entranceGuardManagement/userManagement',
          name: '用户管理',
          icon: '',
          iconUrl: 'iconyonghuguanli',
          component: './Users',
        },
        {
          path: '/entry/entranceGuardManagement/planTemplate',
          name: '计划模板',
          icon: '',
          iconUrl: 'iconjihuamoban',
          component: './PlanTemplate',
        },
        {
          path: '/entry/entranceGuardManagement/authority',
          name: '权限管理',
          icon: '',
          iconUrl: 'iconquanxianguanli',
          component: './Authority',
        },
      ],
    },
    {
      path: '/',
      redirect: '/entry/index',
    },
    {
      component: './404',
    },
  ],
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    // ...darkTheme,
    'primary-color': defaultSettings.primaryColor,
  },
  // @ts-ignore
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[REACT_APP_ENV || 'dev'],
  manifest: {
    basePath: '/',
  },
});
